/**
 * 
 */
package evolution;

import ca.swank.hq.ai.CachingSmartBoard;

/**
 * @author Alon Segal
 *
 */
public class LinearBoardEvaluator implements BoardEvaluator {

	/**
	 * 
	 */
	public LinearBoardEvaluator() {
	}

	/* (non-Javadoc)
	 * @see evolution.BoardFitnessEvaluator#evalFitness(ca.swank.hq.ai.CachingSmartBoard, int)
	 */
	@Override
	public double evalBoard(CachingSmartBoard board, int player) {
		double res = 0;
		int[] loc = board.getPlayerLocation(player);
		int distanceFromDest;
		if(player == 0) {
			distanceFromDest = 10 - loc[1];
		} else {
			distanceFromDest = loc[1];
		}
		int wallsRemains = board.getPlayerWalls(player);
		res =  wallsRemains - 2*distanceFromDest + 20;
		return res;
	}

}
